﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IntelligentDecisioning.SharePoint.Definition;
using Microsoft.SharePoint;
using IntelligentDecisioning.SharePoint.BusinessEntities;
using Microsoft.Practices.SPG.Common.ListRepository;
using IntelligentDecisioning.SharePoint.Helpers;
using IntelligentDecisioning.SharePoint.Definition.Lists;

namespace IntelligentDecisioning.SharePoint.Definitions
{
    class DemonstrationContactList : SharePointContactList
    {
      

        public DemonstrationContactList()
            :base("Demo Contacts List")
        {
           
        }



        public List<DemonstrationContactEntity> GetContacts(SPWeb targetWeb)
        {
            ListItemFieldMapper<DemonstrationContactEntity> entityFieldMapper = new ListItemFieldMapper<DemonstrationContactEntity>();
            entityFieldMapper.FieldMappings = GetFieldMappings();

            List<DemonstrationContactEntity> contacts = new List<DemonstrationContactEntity>();
            IDListHelper listHelper = new IDListHelper(targetWeb.Site, targetWeb);
            SPList demonstrationContactList = listHelper.GetList(Name);
    
            foreach (SPListItem item in demonstrationContactList.Items)
            {
                DemonstrationContactEntity demonstrationContactEntity = entityFieldMapper.CreateEntity(item);
                contacts.Add(demonstrationContactEntity);
            }

            return contacts;
        }
    }
}
